package org.MyToolsProject;

public class StringUtils {

    public static void main(String[] args) {
        String str = "方法2通过判断字符的Unicode脚本是否为汉字";
        for (int i = 0; i < str.length(); i++) {
            char c = str.charAt(i);
            System.out.println(c +":" + isChinese(c) );
        }
    }

    public static boolean isChinese(char c) {
        Character.UnicodeBlock block = Character.UnicodeBlock.of(c);
        return block == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS ||
                block == Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS ||
                block == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A ||
                block == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B ||
                block == Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION ||
                block == Character.UnicodeBlock.CJK_RADICALS_SUPPLEMENT ||
                block == Character.UnicodeBlock.CJK_COMPATIBILITY_FORMS ||
                block == Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT;
    }

    public static boolean isBlank(String str){
        if(str == null){
            return true;
        }
        return str.trim().replace(" ","").replaceAll("\\t","").length() == 0;
    }
}
